<?php
		  
	include ("Outils.inc");
	require ("connect.php");	
		  
	if ( !isset($_COOKIE['identite']) ) {
		  $Nom=$_POST["Nom"];
		  $Code=$_POST["Code"];
		  $mois = 60 * 60 * 24 * 30;

		 identification($Nom, $Code, $serv, "IdentificationD.php");
		 //la fonction identification quitte si l'identification a �chou�
		 
		  	setcookie('identite[0]', "$Nom", time()+ $mois);
			setcookie('identite[1]', "$Code", time()+ $mois);
			$cookieEnvoye = true;
	}
	else {
		$cookieEnvoye = true;
		$identite = $_COOKIE['identite'];
		$Nom = $identite[0];
		$Code = $identite[1];

	}
		  
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css" media="screen">@import "style.css";</style>

<title> VideoExpress - PHP Projet</title></head>

<body>
<div class="center">
<div class="outer" id="outer">
<div class="outer_l">
<div class="outer_r">

<!--ENTETE & MENU-->
<?php 
banniere("VideoExpress","Nguyen Tat Son Tung",$cookieEnvoye);
?>
<!--FIN ENTETE & MENU-->


<!--CONTENT-->
<div class="wrap main_content_max" id="main_content">
<div class="content">
<table class="blog" cellpadding="0" cellspacing="0">
<tr><td valign="top"><div>
		
<table class="contentpaneopen"><tr>
<td class="contentheading" width="100%">LISTE DES CASSETTES DETENUES</td></tr></table>
<table class="contentpaneopen"><tr><td valign="top" colspan="2">
<?php

$req1="SELECT *"
	."FROM `abonnes`"
	."WHERE `Nom` LIKE '$Nom'"
	."AND `Code` LIKE '$Code'";
$req2="SELECT *
	FROM `empres` `e` , `cassettes` `c`
	WHERE `c`.`Statut` LIKE 'empruntee'
	AND `e`.`NoFilm` = `c`.`NoFilm`
	AND `e`.`NoExemplaire` = `c`.`NoExemplaire`
	AND `e`.CodeAbonne = '1Xu123'";
 
$resul1 = DB_execSQL($req1,$serv);
$resul2 = DB_execSQL($req2,$serv);
$count = mysql_num_rows($resul1);

echo "<table><tr><td><img src='images/InfoBox.png'><br \></td>
	<td><div align='right'>
	<form method='POST' action='Deconnecte.php' \">
Deconnect� <input type='image' src='images/deconnect.ico' alt='Deconnecte'>
</form></td></tr></table><br \>"; 

if ( $count == 0 ) {
echo '<img src="images/Cancel2.png"> <br \>';
echo "<font size='2'>Vous n'�tes pas reconnu <br \>"
	."Veuillez verifier votre nom d'abonn� et votre mot de passe</font><br \>";
include ("inc/inc-detenues.php");
}else{

while ($abonne = mysql_fetch_object($resul1)){

if ($abonne->NbCassettes == '0') {

echo "<font size='2'>Vous avez aucune cassette d�tenue</font>";

} else{

echo '<div class="jl_table">
  	<table cellpadding="3" cellspacing="0" border="1">
  	<tr class="sectiontableheader">
	<td width="40" colspan="2"><font size="2">R�f�rence</font></td>
	<td width="40"><font size="2">Date Emprunt</font></td>
	<td width="40"><font size="2"> </font></td>
	<td width="40"><font size="2">Films</font></td>
	<td width="40"><font size="2">R�alisateur</font></td>
	</tr><tr>';
	
while ($empre = mysql_fetch_object($resul2)){

echo '<TR><TD><h2>'.$empre->NoFilm.'</h2>'
	.'<TD><h2>'.$empre->NoExemplaire.'</h2>'
	.'<TD><h2>'.$empre->DateEmpRes.'</h2></TD>'
	.'<TD><img src="images/Device_DVD_RW.png"></TD>';

$req3 ="SELECT *
	FROM `empres` `e` , `films` `f`
	WHERE `e`.`NoFilm` = `f`.`NoFilm`
	AND `e`.`NoFilm` = '$empre->NoFilm'
	AND `e`.`NoExemplaire` ='$empre->NoExemplaire'";

$resul3 = DB_execSQL($req3,$serv);

	while ($film = mysql_fetch_object($resul3)){
echo '<TD><h2>'.$film->Titre.'</h2></TD>'
	.'<TD><h2>'.$film->Realisateur.'</h2></TD></TR>';
}
}
echo '</tr></table></div>';	
}
}
} 

?>
</td></tr></table>

<span class="article_separator">&nbsp;</span>

</div></td></tr></table>
</div>
</div>
</div>
</div>
</div>
</div>
<!--FIN CONTENT-->

<!-- PIED -->
<?php include ("inc/inc-pied.php"); ?>
<!-- FIN - PIED --> 
</body>
</html>